<#-- @ftlvariable name="entity" type="com.xci.platform.auth.entity.ContentEntity" -->
<#include "/_inc/_layout.ftl">
<#import "/auth/_inc/_dic.ftl" as dic>
<#assign url=html.saveUrls("/auth/content/create-save","/auth/content/edit-save")/>
<@header/>
<div class="jxpanel winpanel" data-fit="true">
    <form id="editform" class="jxform" method="post" action="${url}">
        <input name="id" value="${entity.id!}" type="hidden">
        <input id="contentFormat" name="contentFormat" value="${entity.contentFormat!}" type="hidden">
        <textarea id="contentValue" name="contentValue" style="display: none">${entity.contentValue!}</textarea>
        <table class="table jxtable-form" style="width: 98%;">
            <tr>
                <th class="w-60px">编码</th>
                <td style="width: 25%;">
                    <input class="form-control" name="code" value="${entity.code!}" maxlength="50"
                           data-validate="required: [true,'请输入编码'],maxlength: 50" autocomplete="off"/>
                </td>
                <th class="w-60px">名称</th>
                <td style="width: 25%;">
                    <input class="form-control" name="name" value="${entity.name!}" maxlength="50"
                           data-validate="required: [true,'请输入名称'],maxlength: 50" autocomplete="off"/>
                </td>
                <th class="w-60px">分类</th>
                <td style="width: 25%;">
                    <select class="form-control jxselect" name="categoryId" data-allow-clear="true" data-text-field="categoryName">
                        <option></option>
                        <@dic.systemContentCategory selectedValue=entity.categoryId />
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="6">
                    <div class="jxtabs jxtabs-line" style="margin-left: 70px;">
                        <ul class="nav nav-tabs">
                            <li>
                                <a href="#tab-content" data-toggle="tab" data-format="1">HTML</a>
                            </li>
                            <li>
                                <a href="#tab-content" data-toggle="tab" data-format="2">文本</a>
                            </li>
                        </ul>
                        <div class="tab-content">
                            <div id="tab-content" class="tab-pane jx-overflow-auto fade in active">
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <th>备注</th>
                <td colspan="5">
                    <textarea class="form-control" name="remark" maxlength="1000" data-validate="maxlength: 1000" rows="2"
                              style="resize: none">${entity.remark!}</textarea>
                </td>
            </tr>
        </table>
    </form>
    <div class="panel-footer text-right">
        <@html.editPanelFooter/>
    </div>
</div>
<@footer>
    <@html.ueScript/>
    <script src="<@html.url '/auth/js/util/switch-html-text-editor.js'/>"></script>
    <script>
        $('form').on('beforesubmit', function () {
            $('#contentFormat').val(jx.switchHtmlTextEditor.getFormat());
            $('#contentValue').val(jx.switchHtmlTextEditor.getContent());
        });
        jx.ready(function () {
            var htmlOps = {
                initialFrameWidth: '100%',
                initialFrameHeight: 300,
                serverUrl: '<@html.ueditorServerUrl/>'
            };
            var textOps = {
                width: '100%',
                height: '355px',
                cls:'form-control'
            };
            jx.auth.bindEditFormSuccess();
            jx.switchHtmlTextEditor.init($('.jxtabs'), $('#contentValue'),$('#contentFormat').val(), htmlOps,textOps);
        });
    </script>
</@footer>